        <!DOCTYPE html>
<html>
    <head>
        <title>left4dead.js</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <style type="text/css">
            body {
                background-color:black;
                color:white;
            }
            #cwrap {
                margin-left:auto;
                margin-right:auto;
            }
			#canvas1 {
				zoom:3;
			}
        </style>
		<script type="text/javascript">
			// From http://baagoe.com/en/RandomMusings/javascript/
			// Johannes BaagÃ¸e <baagoe@baagoe.com>, 2010
			function Mash() {
				var n = 0xefc8249d;

				var mash = function(data) {
					data = data.toString();
					for (var i = 0; i < data.length; i++) {
						n += data.charCodeAt(i);
						var h = 0.02519603282416938 * n;
						n = h >>> 0;
						h -= n;
						h *= n;
						n = h >>> 0;
						h -= n;
						n += h * 0x100000000; // 2^32
					}
					return (n >>> 0) * 2.3283064365386963e-10; // 2^-32
				};

				mash.version = 'Mash 0.9';
				return mash;
			}
			function Alea() {
				return (function(args) {
					// Johannes BaagÃ¸e <baagoe@baagoe.com>, 2010
					var s0 = 0;
					var s1 = 0;
					var s2 = 0;
					var c = 1;

					if (args.length == 0) {
						args = [+new Date];
					}
					var mash = Mash();
					s0 = mash(' ');
					s1 = mash(' ');
					s2 = mash(' ');

					for (var i = 0; i < args.length; i++) {
						s0 -= mash(args[i]);
						if (s0 < 0) {
							s0 += 1;
						}
						s1 -= mash(args[i]);
						if (s1 < 0) {
							s1 += 1;
						}
						s2 -= mash(args[i]);
						if (s2 < 0) {
							s2 += 1;
						}
					}
					mash = null;

					var random = function() {
						var t = 2091639 * s0 + c * 2.3283064365386963e-10; // 2^-32
						s0 = s1;
						s1 = s2;
						return s2 = t - (c = t | 0);
					};
					random.rand = function(x) {
						return Math.floor(random() * x);
					}
					random.args = args;
					return random;
				} (Array.prototype.slice.call(arguments)));
			};

			/////////////////////////////////////////////////////////////////
            //converted from left4kdead in java
            //http://www.mojang.com/notch/j4k/l4kd/
            
			var mnt=0;
            keyW=87;
            keyA=65;
            keyS=83;
            keyD=68;
            keyR=82;

            canvas=0;
			canvaselem=null;
            imgData=0;
            mouse=0;
            k = []; //128

            sprites = []; //18 * 4 * 16 * 12 * 12

			//int
            score = 0;
            hurtTime = 0;
            bonusTime = 0;
			//win rect?
            xWin0 = 0;
            yWin0 = 0;
            xWin1 = 0;
            yWin1 = 0;
            lightmap = new Uint8Array(240*240); //240*240
            brightness = new Uint8Array(512); //512
            map = new Uint32Array(1024*1024); //1024*1024
			monsterData = []; //320*16


			/*
[0] x
[1] y
[2] aggro? (0-15)
[3] ++ (how many movements)
[8] rand(25) ==12:
[9] monsterhealth? (127 oder 0)
[10] ??? 0-x
[11] 0=empty 1=player/monster
[15] color?
			 */

            ///////////////////////////////////////////

            function mkint(x) {
                return parseInt(x);
            }
            function rand(max) {
                return parseInt(Math.random()*max);
            }
            function setPixel(pos,pix) {
                pos=mkint(pos) << 2;
				pix=mkint(pix);
                imgData.data[pos+2] = pix & 0xff;
                pix = pix >> 8;
                imgData.data[pos+1] = pix & 0xff;
                pix = pix >> 8;
                imgData.data[pos] = pix & 0xff;
            }

            function initArr(arr,l,bits) {
				for (var i=0;i<l;i++) arr[i]=0;
			}

            ///////////////////////////////////////////

            function init() {
                canvaselem = document.getElementById('canvas1');
                canvas = canvaselem.getContext('2d');
                canvas.fillStyle = 'rgb(0,0,0);';
                canvas.fillRect(0,0,240,240);
                canvas.fillStyle = 'rgb(255,255,255);';

				initArr(lightmap,240*240,8);
				initArr(brightness,512,8);
				initArr(map,1024*1024,32);
				initArr(monsterData,320*16,8);
                initArr(sprites,18 * 4 * 16 * 12 * 12,32);
                initArr(k,128,8);

                imgData = canvas.getImageData(0,0,240,240);

				for (var i=0; i<512; i++) {
					brightness[i] = 0;
				}
				for (var i=0; i<240*240; i++) {
					lightmap[i] = 0;
				}

				//generate sprites
				var pix=0;
				for (var i = 0; i < 18; i++)
				{
					var skin = 0xFF9993;
					var clothes = 0xFFffff;

					if (i > 0)
					{
						skin = 0xa0ff90;
						clothes = rand(0x1000000) & 0x7f7f7f;
					}
					for (var t = 0; t < 4; t++)
					{
						for (var d = 0; d < 16; d++)
						{
							//dbl
							var dir = d * Math.PI * 2 / 16.0;

							if (t == 1) dir += 0.5 * Math.PI * 2 / 16.0;
							if (t == 3) dir -= 0.5 * Math.PI * 2 / 16.0;

							//                    if (i == 17)
							//                    {
							//                        dir = d * Math.PI * 2 / 64;
							//}
							//dbl
							var cos = Math.cos(dir);
							var sin = Math.sin(dir);

							for (var y = 0; y < 12; y++)
							{
								var col = 0x000000;
								for (var x = 0; x < 12; x++)
								{
									var xPix = mkint( (cos * (x - 6) + sin * (y - 6) + 6.5) );
									var yPix = mkint( (cos * (y - 6) - sin * (x - 6) + 6.5) );

									if (i == 17)
									{
										if (xPix > 3 && xPix < 9 && yPix > 3 && yPix < 9)
										{
											col = 0xff0000 + (t & 1) * 0xff00;
										}
									}
									else
									{
										if (t == 1 && xPix > 1 && xPix < 4 && yPix > 3 && yPix < 8) col = skin;
										if (t == 3 && xPix > 8 && xPix < 11 && yPix > 3 && yPix < 8) col = skin;

										if (xPix > 1 && xPix < 11 && yPix > 5 && yPix < 8)
										{
											col = clothes;
										}
										if (xPix > 4 && xPix < 8 && yPix > 4 && yPix < 8)
										{
											col = skin;
										}
									}
									sprites[pix++] = col;
									if (col > 1)
									{
										col = 1;
									}
									else
									{
										col = 0;
									}
								}
							}
						}
					}
				}

				restart();
				//winLevel();
				run();
			}//init


			gameStarted = false;
			//int
			level = 0;
			shootDelay = 0;
			shootCasing = 0;
			shotIdx = 0;
			rushTime = 150;
			damage = 20;
			ammo = 20;
			clips = 20;
			function restart() {
				winLevel();
				gameStarted = false;
				level = 0;
				shootDelay = 0;
				shootCasing = -100;
				rushTime = 150;
				damage = 20;
				ammo = 20;
				clips = 20;
			}

			tick = 0;
			offs = 30;//const?
			playerDir = 0;
			function winLevel() {
				tick=0;
				level++;
				var alea = new Alea(level);

				//floor
				var i = 0;
				for (var y = 0; y < 1024; y++)
					for (var x = 0; x < 1024; x++)
				{
					var br = alea.rand(32) + 112;
					map[i] = (mkint(br / 3) << 16) | (br << 8);
					if (x < 4 || y < 4 || x >= 1020 || y >= 1020)
					{
						map[i] = 0xFFFEFE;
					}
					i++;
				}

				//generate room
				for (i = 0; i < 70; i++)
				{
					var w = 2+alea.rand(8);
					var h = 2+alea.rand(8);
					var xm = alea.rand(64 - w - 2) + 1;
					var ym = alea.rand(64 - h - 2) + 1;

					w=w<<4;
					h=h<<4;

					w += 5;
					h += 5;
					xm=xm<<4;
					ym=ym<<4;

					if (i==68)
					{
						monsterData[0] = (xm+w)>>1;
						monsterData[1] = (ym+h)>>1;
						monsterData[15] = 0x808080;
						monsterData[11] = 1;
					}

					//rooms?
					xWin0 = xm+5;
					yWin0 = ym+5;
					xWin1 = xm + w-5;
					yWin1 = ym + h-5;
					for (var y = ym; y < ym + h; y++)
						for (var x = xm; x < xm + w; x++)
					{
						var d = x - xm;
						if (xm + w - x - 1 < d) d = xm + w - x - 1;
						if (y - ym < d) d = y - ym;
						if (ym + h - y - 1 < d) d = ym + h - y - 1;

						map[x + y * 1024] = 0xFF8052;
						if (d > 4)
						{
							var br = alea.rand(16) + 112;
							if (((x + y) & 3) == 0)
							{
								br += 16;
							}
							//floor color
							map[x + y * 1024] = (mkint((br * 3) / 3) << 16) | (mkint((br * 4) / 4) << 8) | mkint((br * 4) / 4);
						}
						if (i == 69)
						{
							//marker?
							map[x + y * 1024] &= 0xff0000;
						}
					}

					//doors
					for (var j = 0; j < 2; j++)
					{
						var xGap = alea.rand(w - 24) + xm + 5;
						var yGap = alea.rand(h - 24) + ym + 5;
						var ww = 5;
						var hh = 5;

						xGap = mkint(((xGap / 16) * 16) + 5);
						yGap = mkint(((yGap / 16) * 16) + 5);
						if (alea.rand(4) < 2)
						{
							xGap = xm + (w - 5) * alea.rand(2);
							hh = 11;
						}
						else
						{
							ww = 11;
							yGap = ym + (h - 5) * alea.rand(2);
						}
						//door color
						for (var y = yGap; y < yGap + hh; y++)
							for (var x = xGap; x < xGap + ww; x++)
						{
							var br = alea.rand(32) + 112 - 64;
							map[x + y * 1024] = mkint((br * 3) / 3) << 16 | mkint((br * 4) / 4) << 8 | mkint((br * 4) / 4);
						}
					}
				}//rooms/player

				//fill insides of wall
				for (var y = 1; y < 1024 - 1; y++)
					inloop: for (var x = 1; x < 1024 - 1; x++)
				{
					for (var xx = x - 1; xx <= x + 1; xx++)
						for (var yy = y - 1; yy <= y + 1; yy++)
							if (map[xx + yy * 1024] < 0xff0000) continue inloop;

					map[x + y * 1024] = 0xffffff;
				}

				offs = 30;
				playerDir = 0;
				for (i = 0; i < 512; i++)
				{
					brightness[i] = mkint(255 * offs / (i + offs));
					if (i < 4) brightness[i] = brightness[i] * i >> 2;
				}
			}

			xCam=0;
			yCam=0;
			xPos=0;
			yPos=0;
			shootDir=0;
			cos=0;
			sin=0;

			function run() {

				if (gameStarted)
				{
					tick++;
					rushTime++;

					if (rushTime >= 150)
					{
						rushTime = -rand(2000);
					}

					/* move ply */
					playerDir = Math.atan2(mkint(mouse / 240) - 120, mouse % 240 - 120);

					//dbl
					var shootDir = playerDir + (rand(100) - rand(100)) / 100.0 * 0.2;
					var cos = Math.cos(-shootDir);
					var sin = Math.sin(-shootDir);

					var xCam = monsterData[0];
					var yCam = monsterData[1];

					//draw everything
					for (var i = 0; i < 960; i++)
					{
						var xt = i % 240 - 120;
						var yt = (mkint(i / 240) % 2) * 239 - 120;

						if (i >= 480)
						{
							var tmp = xt;
							xt = yt;
							yt = tmp;
						}

						var dd = Math.atan2(yt, xt) - playerDir;
						if (dd < -Math.PI) dd += Math.PI * 2;
						if (dd >= Math.PI) dd -= Math.PI * 2;

						var brr = mkint((1 - dd * dd) * 255);

						var dist = 120;
						if (brr < 0)
						{
							brr = 0;
							dist = 32;
						}
						if (tick < 60) brr = mkint(brr * tick / 60);

						//lamp + player
						var j = 0;
						for (; j < dist; j++)
						{
							var xx = xt * j / 120 + 120;
							var yy = yt * j / 120 + 120;
							var xm = xx + xCam - 120;
							var ym = yy + yCam - 120;

							if (map[(mkint(xm) + mkint(ym) * 1024) & (1024 * 1024 - 1)] == 0xffffff) break;

							var xd = (xx - 120) * 256 / 120;
							var yd = (yy - 120) * 256 / 120;

							var ddd = mkint((xd * xd + yd * yd) / 256);
							var br = brightness[ddd] * brr / 255;

							if (ddd < 16)
							{
								var tmp = mkint(128 * (16 - ddd) / 16);
								br = br + tmp * (255 - br) / 255;
							}

							lightmap[mkint(xx) + mkint(yy) * 240] = mkint(br);
						}
					}

					//map to pixel
					for (var y = 0; y < 240; y++)
					{
						var xm = xCam - 120;
						var ym = y + yCam - 120;
						for (var x = 0; x < 240; x++)
						{
							setPixel(x + y * 240,map[(xm + x + ym * 1024) & (1024 * 1024 - 1)]);
						}
					}

					var closestHitDist = 0;
					for (var j = 0; j < 250; j++)
					{
						var xm = xCam + mkint(cos * j / 2);
						var ym = yCam - mkint(sin * j / 2);
						if (map[(xm + ym * 1024) & (1024 * 1024 - 1)] == 0xffffff) break;
						closestHitDist = mkint(j / 2);
					}

					var shoot = (shootDelay-- < 0) && k[1];

					var closestHit = 0;

					nextMonster: for (var m = 0; m < 256 + 16; m++)
					{
						var xPos = monsterData[m * 16 + 0];
						var yPos = monsterData[m * 16 + 1];
						if (monsterData[m * 16 + 11] <= 0)
						{
							xPos = (rand(62) + 1) * 16 + 8;
							yPos = (rand(62) + 1) * 16 + 8;

							var xd = xCam - xPos;
							var yd = yCam - yPos;

							if (xd * xd + yd * yd < 180 * 180)
							{
								xPos = 1;
								yPos = 1;
							}

							if ((map[xPos + yPos * 1024] < 0xfffffe) && ((m <= 128) || (rushTime > 0) || ((m > 255) && (tick == 1))))
							{
								monsterData[m * 16 + 0] = xPos;
								monsterData[m * 16 + 1] = yPos;
								monsterData[m * 16 + 15] = map[xPos + yPos * 1024];
								map[xPos + yPos * 1024] = 0xfffffe;
								monsterData[m * 16 + 9] = ((rushTime > 0) || (rand(3) < 2)) ? 127 : 0;
								monsterData[m * 16 + 11] = 1;
								monsterData[m * 16 + 2] = m & 15;
							}
							else
							{
								continue;
							}
						}
						else
						{
							var xd = xPos - xCam;
							var yd = yPos - yCam;

							//ammoclip, health
							if (m >= 255)
							{
								if (xd * xd + yd * yd < 8 * 8)
								{
									map[xPos + yPos * 1024] = monsterData[m * 16 + 15];
									monsterData[m * 16 + 11] = 0;
									bonusTime = 120;
									if ((m & 1) == 0)
									{
										damage = 20;
									}
									else
									{
										clips = 20;
									}
									continue;
								}
							}
							else if (xd * xd + yd * yd > 340 * 340)
							{
								map[xPos + yPos * 1024] = monsterData[m * 16 + 15];
								monsterData[m * 16 + 11] = 0;
								continue;
							}
						}


						var xm = xPos - xCam + 120;
						var ym = monsterData[m * 16 + 1] - yCam + 120;

						var d = monsterData[m * 16 + 2];
						if (m == 0)
						{
							d = ((mkint(playerDir / (Math.PI * 2) * 16 + 4.5 + 16)) & 15);

						}

						d += mkint(((monsterData[m * 16 + 3] / 4) & 3) * 16);


						var p = (0 * 16 + d) * 144;
						if (m > 0)
						{
							p += ((m & 15) + 1) * 144 * 16 * 4;
						}

						if (m > 255)
						{
							p = (17 * 4 * 16 + ((m & 1) * 16 + (tick & 15))) * 144;
						}

						//draw monster
						for (var y = ym - 6; y < ym + 6; y++)
							for (var x = xm - 6; x < xm + 6; x++)
						{
							var c = sprites[p++];
							if (c > 0 && x >= 0 && y >= 0 && x < 240 && y < 240)
							{
								setPixel(x + y * 240,c);
							}
						}


						var moved = false;

						if (monsterData[m * 16 + 10] > 0)
						{
							monsterData[m * 16 + 11] += rand(3) + 1;
							monsterData[m * 16 + 10] = 0;
							//dbl
							var rot = 0.25;
							var poww = 32;

							var amount = 8;

							if (monsterData[m * 16 + 11] >= 2+level)
							{
								rot = Math.PI * 2;
								amount = 60;
								poww = 16;
								map[(xPos) + (yPos) * 1024] = 0xa00000;
								monsterData[m * 16 + 11] = 0;
								score += level;
							}
							for (var i = 0; i < amount; i++)
							{
								var pow = (rand(100) * rand(100)) * poww / 10000+4;
								var dir = (rand(100) - rand(100)) / 100.0 * rot;
								var xdd = (Math.cos(playerDir + dir) * pow) + rand(4) - rand(4);
								var ydd = (Math.sin(playerDir + dir) * pow) + rand(4) - rand(4);
								var col = mkint(rand(128) + 120);
								bloodLoop: for (var j = 2; j < pow; j++)
								{
									var xd = mkint(xPos + xdd * j / pow);
									var yd = mkint(yPos + ydd * j / pow);
									var pp = ((xd) + (yd) * 1024) & (1024 * 1024 - 1);
									if (map[pp] >= 0xff0000) break bloodLoop;
									if (rand(2) != 0)
									{
										map[pp] = col << 16;
										col = mkint(col * 8 / 9);
									}
								}
							}

							continue nextMonster;
						}

						var xPlayerDist = xCam - xPos;
						var yPlayerDist = yCam - yPos;

						if (m <= 255)
						{
							var rx = -(cos * xPlayerDist - sin * yPlayerDist);
							var ry = cos * yPlayerDist + sin * xPlayerDist;

							if (rx > -6 && rx < 6 && ry > -6 && ry < 6 && m > 0)
							{
								damage++;
								hurtTime += 20;
							}
							if (rx > -32 && rx < 220 && ry > -32 && ry < 32 && rand(10) == 0)
							{
								monsterData[m * 16 + 9]++;
							}
							if (rx > 0 && rx < closestHitDist && ry > -8 && ry < 8)
							{
								closestHitDist = mkint(rx);
								closestHit = m;
							}

							dirLoop: for (var i = 0; i < 2; i++)
							{
								var xa = 0;
								var ya = 0;
								xPos = monsterData[m * 16 + 0];
								yPos = monsterData[m * 16 + 1];

								if (m == 0)
								{
									if (k[keyA]) xa--;
									if (k[keyD]) xa++;
									if (k[keyW]) ya--;
									if (k[keyS]) ya++;
								}
								else
								{
									if (monsterData[m * 16 + 9] < 8) continue nextMonster;

									if (monsterData[m * 16 + 8] != 12)
									{
										xPlayerDist = (monsterData[m * 16 + 8]) % 5 - 2;
										yPlayerDist = (monsterData[m * 16 + 8]) / 5 - 2;
										if (rand(10) < 1)
										{
											monsterData[m * 16 + 8] = 12;
										}
									}

									var xxd = Math.sqrt(xPlayerDist * xPlayerDist);
									var yyd = Math.sqrt(yPlayerDist * yPlayerDist);
									if (rand(1024) / 1024.0 < yyd / xxd)
									{
										if (yPlayerDist < 0) ya--;
										if (yPlayerDist > 0) ya++;
									}
									if (rand(1024) / 1024.0 < xxd / yyd)
									{
										if (xPlayerDist < 0) xa--;
										if (xPlayerDist > 0) xa++;
									}

									moved = true;
									var dir = Math.atan2(yPlayerDist, xPlayerDist);
									monsterData[m * 16 + 2] = ((mkint(dir / (Math.PI * 2) * 16 + 4.5 + 16)) & 15);
								}

								ya *= i;
								xa *= 1 - i;

								if (xa != 0 || ya != 0)
								{
									map[xPos + yPos * 1024] = monsterData[m * 16 + 15];
									for (var xx = xPos + xa - 3; xx <= xPos + xa + 3; xx++)
										for (var yy = yPos + ya - 3; yy <= yPos + ya + 3; yy++)
											if (map[xx + yy * 1024] >= 0xfffffe)
									{
										map[xPos + yPos * 1024] = 0xfffffe;
										monsterData[m * 16 + 8] = rand(25);
										continue dirLoop;
									}

									moved = true;
									monsterData[m * 16 + 0] += xa;
									monsterData[m * 16 + 1] += ya;
									monsterData[m * 16 + 15] = map[(xPos + xa) + (yPos + ya) * 1024];
									map[(xPos + xa) + (yPos + ya) * 1024] = 0xfffffe;
								}
							}
							if (moved)
							{
								monsterData[m * 16 + 3]++;
							}
						}
					}

					if (shootCasing>-30) {
						shootCasing--;
						if (shootCasing==-5) {
							sound(rand(2)+5);
						}
					}

					if (shoot)
					{
						shootCasing=0;
						sound(10+shotIdx);
						if (++shotIdx>3) {
							shotIdx=0;
						}

						if (rand(50)<10) {
							sound(rand(1)+3);
						}

						if (ammo >= 220)
						{
							shootDelay = 2;
							k[1] = false;
						}
						else
						{
							shootDelay = 1;
							ammo += 4;
						}
						if (closestHit > 0)
						{
							monsterData[closestHit * 16 + 10] = 1;
							monsterData[closestHit * 16 + 9] = 127;
						}
						var glow = 0;
						for (var j = closestHitDist; j >= 0; j--)
						{
							var xm = +mkint(cos * j) + 120;
							var ym = -mkint(sin * j) + 120;
							if (xm > 0 && ym > 0 && xm < 240 && ym < 240)
							{
								if (rand(20) == 0 || j == closestHitDist)
								{
									setPixel(xm + ym * 240, 0xffffff);
									glow = 200;
								}
								lightmap[xm + ym * 240] += mkint(glow * (255 - lightmap[xm + ym * 240]) / 255);
							}
							glow = glow * 20 / 21;
						}//for j

						if (closestHitDist < 120)
						{
							closestHitDist -= 3;
							var xx = mkint(120 + cos * closestHitDist);
							var yy = mkint(120 - sin * closestHitDist);

							for (var x = -12; x <= 12; x++)
							{
								for (var y = -12; y <= 12; y++)
								{
									var xd = mkint(xx + x);
									var yd = mkint(yy + y);
									if (xd >= 0 && yd >= 0 && xd < 240 && yd < 240)
									{
										lightmap[xd + yd * 240] += mkint( 2000 / (x * x + y * y + 10) * (255 - lightmap[xd + yd * 240]) / 255 );
									}
								}
							}//for x<12

							for (var i = 0; i < 10; i++)
							{
								var pow = rand(100) * rand(100) * 8.0 / 10000;
								var dir = (rand(100) - rand(100)) / 100.0;
								var xd = mkint(xx - Math.cos(playerDir + dir) * pow) + rand(4) - rand(4);
								var yd = mkint(yy - Math.sin(playerDir + dir) * pow) + rand(4) - rand(4);
								if (xd >= 0 && yd >= 0 && xd < 240 && yd < 240)
								{
									if (closestHit > 0)
									{
										setPixel(xd + yd * 240, 0xff0000);
									}
									else
									{
										setPixel(xd + yd * 240, 0xcacaca);
									}
								}
							}//for i<10
						}//closestHitDist<120
					}//shoot


					if (damage >= 220)
					{
						k[1] = false;
						hurtTime = 255;
						restart();
					}
					if (k[keyR] && ammo > 20 && clips < 220)
					{
						shootDelay = 30;
						ammo = 20;
						clips += 10;
						sound(2);
					}

					if (xCam > xWin0 && xCam < xWin1 && yCam > yWin0 && yCam < yWin1)
					{
						winLevel();
					}
				}//gamestarted

				bonusTime = mkint(bonusTime * 8 / 9);
				hurtTime = mkint(hurtTime / 2);

				for (var y = 0; y < 240; y++)
				{
					for (var x = 0; x < 240; x++)
					{
						var noise = rand(16);
						if (!gameStarted) noise *= 4;

						var ioff = (x+(y*240))*4;
						var l = lightmap[x + y * 240];
						lightmap[x + y * 240] = 0;
						var r = imgData.data[ioff] * l / 255 + noise;
						var g = imgData.data[ioff+1] * l / 255 + noise;
						var b = imgData.data[ioff+2] * l / 255 + noise;

						r = r * (255 - hurtTime) / 255 + hurtTime;
						g = g * (255 - bonusTime) / 255 + bonusTime;
						imgData.data[ioff] = r;
						imgData.data[ioff+1] = g;
						imgData.data[ioff+2] = b;
					}

					if (y % 2 == 0 && (y >= damage && y < 220))
					{
						for (var x = 232; x < 238; x++)
						{
							setPixel(y * 240 + x, 0x800000);
						}
					}
					if (y % 4 == 0 && (y >= ammo && y < 220))
					{
						for (var x = 224; x < 230; x++)
						{
							setPixel(y * 240 + x, 0x808000);
							setPixel((y+1) * 240 + x, 0x808000);
						}
					}
					if (y % 10 < 9 && (y >= clips && y < 220))
					{
						for (var x = 221; x < 222; x++)
						{
							setPixel(y * 240 + 221, 0xffff00);
						}
					}
				}

				canvas.putImageData(imgData,0,0);

				canvas.fillText("" + score, 4, 232);
				if (!gameStarted)
				{
					canvas.fillText("Left 4k Dead", 80, 70);
					if (k[1] && hurtTime == 0)
					{
						score = 0;
						gameStarted = true;
						k[1] = false;
					}
				}
				else if (tick < 60)
				{
					canvas.fillText("Level " + level, 90, 70);
				}


				window.setTimeout('run()',10);
			}//run

			function key(e,down) {
				k[e.which]=down?1:0;
			}

			function mousek(e,down) {
				k[1]=down?1:0;
			}

			function mousem(e) {
				mouse= Math.min(240,(e.x/canvaselem.style.zoom)-10) + (240*Math.min(240,(e.y/canvaselem.style.zoom)-10));
			}

			function sound(no) {
				var el = document.getElementById('s'+no);
				if (el) {
//                            el.currentTime=0;
					el.play();
				}
			}

        </script>
    </head>
    <body onload="init();"
          onkeydown="key(event,true);return false;"
          onkeyup="key(event,false);return false;"
          onmousedown="mousek(event,true);return false;"
          onmouseup="mousek(event,false);return false;"
          onmousemove="mousem(event);return false;">
        <div id="cwrap">
		<canvas id="canvas1" width="240" height="240">
            no canvas support
        </canvas>
		</div>
		<audio src="background.mp3" autoplay loop />
		<audio id="s2" src="reload.mp3" preload="auto" />
		<audio id="s3" src="rico1.mp3" preload="auto" />
		<audio id="s4" src="rico2.mp3" preload="auto" />
		<audio id="s5" src="casing1.mp3" preload="auto" />
		<audio id="s6" src="casing2.mp3" preload="auto" />
		<audio id="s7" src="casing3.mp3" preload="auto" />
		<audio id="s10" src="shot.mp3" preload="auto" />
		<audio id="s11" src="shot.mp3" preload="auto" />
		<audio id="s12" src="shot.mp3" preload="auto" />
		<audio id="s13" src="shot.mp3" preload="auto" />

    </body>
</html>